<% extends 'stock/weui_base.html' %>
<% block title %>理货单<% endblock %>
<% block body %>
<style>
    .weui_input{text-align: right}

    .weui-input-right{
    border-left: 1px solid #e5e5e5;
    color: #aaa;
    display: inline-block;
    font-size: 17px;
    height: 44px;
    line-height: 44px;
    margin-left: 5px;
    padding: 0 .6em 0 .7em;
    vertical-align: middle;
    }
</style>
<script>
    var so_id = ${so_id};
     var from = '${from}';
    var lines_remainder = ${lines_remainder|to_json|safe};
    var picking_list = ${exists_picking_simple_list|to_json|safe};
</script>
<!-- 已有出库单列表模版 -->
<script type="x-template" id="expandable-category-template">
<div class="page-bd">
    <ul>
        <li class="js-show">
            <div class="weui-flex js-category" v-on:touch="expand_or_collapse" v-on:click="expand_or_collapse">
                <div class="weui-flex-item">{{title}}</div>
                <i class="icon icon-74"></i>
            </div>
            <slot>
            <div class="page-category js-categoryInner">
                <div class="weui_cells weui_cells_access" style="margin-top: 0px;">
                    <a class="weui_cell" v-for="picking in picking_list" v-bind:href="skip_url + picking.picking_id+'?from='+ from">
                        <div class="weui_cell_bd weui_cell_primary">
                            <p>{{picking.type}}{{picking.name}}
                                <template v-if="picking.state=='done'">
                                    <apan>(完成)</apan>
                                </template>
                                <template v-else>
                                    <apan v-if="picking.state=='assigned'">(已保留)</apan>
                                    <span v-if="picking.state!='assigned' && picking.state!='done'">(未保留)</span>
                                </template>
                            </p>
                        </div>
                        <div class="weui_cell_ft">{{picking.products_count}}产品</div>
                    </a>
                </div>
            </div>
            </slot>
        </li>
    </ul>
</div>
</script>
<div id="form-tally">
<% if len(exists_picking_simple_list) > 0 %>
<expandable-category title="已有的出库单" remote-data="/wx/api/so/${so_id}/pickings/list"></expandable-category>
<% endif %>
<h3 v-if="is_whole_picking" style="text-align: center">已全部建立出库单</h3>
<h3 v-if="!is_whole_picking" style="text-align: center">输入本次发货数量</h3>
<form v-bind:class="{'hide': is_whole_picking}">
    <input id="so_id" name="so_id" type="hidden" value="${so_id}" />
    <div class="weui_cells weui_cells_form">
    <% for order_line in order_lines %>
        <div class="weui_cells_title">${order_line.name}</div>
        <div class="weui_cells">
            <div class="weui_cell weui_vcode" manual-valid="true">
                <div class="weui_cell_hd"><label for="" class="weui_label">总${order_line.qty|int},本次:</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input id="qty_${order_line.id}" name="${order_line.id}" class="weui_input" type="number" pattern="[0-9]*" required placeholder="请输入本次发货数量" value="${lines_remainder[order_line.id].remainder_delivery_qty|int}" v-model="lines_remainder[${order_line.id}].remainder_delivery_qty">
                </div>
                <div class="weui_cell_ft">
                    <i class="weui_icon_warn"></i>
                    <span class="weui-input-right" v-bind:class="{ 'weui_cell_warn': !lines_stock_enough[${order_line.id}] }">
                       库存:{{ lines_remainder[${order_line.id}].available_without_reservation }} ({{ lines_remainder[${order_line.id}].locked_quant_qty }})</span>
                </div>
            </div>
        </div>
    <% endfor %>
    </div>
    <div class="weui_btn_area">
        <a id="formSubmitBtn" href="javascript:" class="weui_btn weui_btn_primary" v-on:click="submit">
            <template v-if="is_whole_picking">建立整批发货单</template>
            <template v-else>建立发货单</template>
        </a>
    </div>
</form>
</div>
<script src="/dftg_weixin/static/src/js/stock/stock_app.js?v=1.064"></script>
<% endblock %>
